import request from '@/utils/request'

/**
 * 获取车辆列表
 * @param {Object} params 查询参数
 */
export function getVehicleList(params) {
  return request({
    url: '/car-vehicle/vehicles/page',
    method: 'get',
    params
  })
}

/**
 * 获取车辆详情
 * @param {String|Number} id 车辆ID
 */
export function getVehicleDetail(id) {
  return request({
    url: `/car-vehicle/vehicles/detail/${id}`,
    method: 'get'
  })
}

/**
 * 获取车辆品牌列表
 */
export function getVehicleBrands() {
  return request({
    url: '/car-vehicle/vehicle-brands/list',
    method: 'get'
  })
}

/**
 * 获取车辆系列列表
 * @param {String|Number} brandId 品牌ID
 */
export function getVehicleSeries(brandId) {
  return request({
    url: `/car-vehicle/vehicle-series/list/brand/${brandId}`,
    method: 'get'

  })
}

/**
 * 检查车辆可用性
 * @param {String|Number} id 车辆ID
 * @param {String} startDate 开始日期
 * @param {String} endDate 结束日期
 */
export function checkVehicleAvailability(id, startDate, endDate) {
  return request({
    url: '/vehicle/check-availability',
    method: 'get',
    params: {
      id,
      startDate,
      endDate
    }
  })
}

/**
 * 获取推荐车辆
 * @param {Object} params 查询参数
 */
export function getRecommendVehicles(params) {
  return request({
    url: '/car-vehicle/vehicles/recommend',
    method: 'get',
    params
  })
}

// 获取热门车辆
export function getHotVehicles(limit = 6) {
  return request({
    url: '/car-search/vehicle/hot',
    method: 'get',
    params: { limit }
  })
}

/**
 * 记录车辆浏览次数
 * @param {String|Number} id 车辆ID
 */
export function recordVehicleView(id) {
  return request({
    url: `/car-search/vehicle/${id}/view`,
    method: 'post'
  })
} 